1. Field of the Invention
The present invention relates in general to video encoding, and more specifically to a system and method of adaptive rate control for a video encoder.
2. Description of the Related Art
Video standards are continuously being improved or otherwise replaced to improve performance and quality for a variety of applications. For example, the Advanced Video Coding (AVC) standard, Part 10 of MPEG4 (Motion Picture Experts Group), otherwise known as H.264, includes advanced compression techniques that were developed to enable transmission of video signals at a lower bit rate or to enable improved video quality at a given transmission rate. The H.264 is used for exemplary embodiments of the present invention although it is understood that the present invention is not limited to H.264 and is applicable to other video standards. The newer standard outperforms video compression techniques of prior standards in order to support higher quality streaming video at lower bit rates and to enable internet-based video and wireless applications and the like. The standard defines the syntax of the encoded video bit stream along with a method of decoding the bit stream. Each video frame is subdivided into one or more slices and encoded at the macroblock (MB) level, where each MB is a 16×16 block of pixels. The size of each slice is arbitrary and may range between a single MB up to all of the MBs in the frame. Each frame is also subdivided according to a rate control interval, specified as a number of MBs per interval, where the rate control interval also ranges between a single MB up to all of the MBs in the frame. The slice size and interval size may be, but are not necessarily, the same.
The H.264 standard employs a transform process for encoding, such as the Discrete Cosine Transform (DCT) compression process. A quantization parameter (QP) is used by the encoder for quantizing the transform coefficients. Although prior video standards defined a linear relationship between QP and a corresponding quantization step size, H.264 specifies a logarithmic relationship. At higher values of QP, a relatively small change of QP results in a relatively large change in the quantization step size applied during the quantization process. The encoder uses a rate controller to control the bit rate of the compressed video stream provided at the output of the encoder. The rate control mechanism adjusts coding parameters, such as QP, frame rate, target bit rate, etc. to meet a given “bit budget” by dynamically allocating the bits at various levels, including group of pictures (GOP), picture or frame, interval or slice, and macroblock. A variable bit rate (VBR) encoder uses a fixed QP to provide a relatively constant visual quality, which is suitable for program stream applications such as VCD, DVD players, and the like. A constant bit rate (CBR) encoder adjusts QP to maintain a relatively constant bit rate (with variable visual quality), which is suitable for transport stream applications (e.g., two-way visual communications) with a relatively fixed or low-bandwidth channel.
Real-time visual communication requires that the compressed video data be transmitted through a communication channel at a specified constant bit rate in a low-delay, or a very low-delay mode. The rate control algorithm performs this task by dynamically adjusting encoder parameters, including QP, to achieve a given target bit rate. It has proved to be difficult to maintain coding efficiency, however, while also maintaining a constant bit rate in a real-time encoding application employing the conventional linear or quadratic prediction process used for predicting QP. For example, the conventional linear prediction method to adjust QP is to use the buffer status and other statistic coding information for coding the current MB, or interval. This conventional linear method for predicting QP works well for video with simple content or with relatively small motion content because the difference between the current QP and the previous QP (where the difference is referred to herein as “deltaQP”) is sufficiently small. For video sequences with a significant amount of motion, however, deltaQP becomes unpredictable due to the inaccurate estimation of QP, which causes large fluctuations among the encoded intervals and which results in significantly reduced coding efficiency. The conventional predictive method is not accurate because it does not provide an adequate analytic expression between QP and the number of bits used for encoding. And the conventional prediction method causes QP to easily exceed the maximum value specified by the H.264 video coding standard, which results in a non-efficient and often uncontrollable rate-distortion process, such as oscillation of the visual quality between frames or slices.
One method to reduce the large and undesirable fluctuations is to simply cap or cramp the deltaQP within a small range. The relatively small cap, however, still causes the fluctuation problem because it ignores the amplitude of the deltaQP, and thus ignores the estimated QP. Ignoring the amplitude of deltaQP is more serious in the H.264 encoder when QP, which has a greater range (0-51) compared to prior standards, is relatively large, such as 40 or above. A large QP results in a much higher quantization step size due to the logarithmic relationship even in a small range, so that the resulting encoded picture quality is significantly depreciated. And the problem simply gets worse when the error is propagated and increased with subsequent frames. In addition, simply capping deltaQP within a fixed range (e.g. [−2, 2]) often causes QP to oscillate between fixed values, thereby degrading picture quality. For example, the value of QP often simply alternates between QP and QP+2.
In this manner, the conventional prediction for calculating QP resulted in a relatively wide range of QP when applied to newer video standards, such as the H.264 standard. It is desired to provide a system and method of adaptive rate control for a video encoder.